package page.app.wallet;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;

import basicTool.WaitTool;
import io.appium.java_client.AppiumDriver;
import page.app.AbstractAppPage;

public class WalletPage extends AbstractAppPage {

    @FindBy(xpath = "//UIAStaticText[@name='钱包']|//android.widget.RelativeLayout/android.widget.TextView[@text='钱包']")
    private WebElement walletLabel;

    @FindBy(xpath = "//UIATableCell[3]/UIAButton[1]|//android.widget.TextView[@text='余额生息']")
    private WebElement tradeCaptialButton;

    @FindBy(xpath = "//android.widget.RelativeLayout[1]/android.view.View[1]|//UIAApplication/UIAWindow/UIATableView/UIAButton[1]")
    private WebElement photoButton;
    
    @FindBy(xpath ="//UIATableCell[5]/UIAButton[2]|//android.widget.RelativeLayout[8]")  //九宫格第3行第2个，保险
    private WebElement insuranceButton;
    
    @FindBy(xpath ="//UIATableCell[5]/UIAButton[3]|//android.widget.RelativeLayout[9]") //九宫格第3行第3个，红包卡券
    private WebElement packetAndTicketButton;
    
    @FindBy(xpath ="//UIAButton[contains(@name,'借入')|//android.widget.TextView[@text='借入']]")  //借入按钮
    private WebElement lendButton;
    
    @FindBy(xpath ="//UIAButton[contains(@name,'借出')]|//android.widget.TextView[@text='借出']")  //借出按钮
    private WebElement borrowButton;
    
    @FindBy(xpath ="//UIAButton[contains(@name,'赚利差')]|//android.widget.TextView[@text='赚利差']")  //赚利差按钮
    private WebElement earnButton;

    public WalletPage(AppiumDriver appiumDriver) {
        super(appiumDriver);
        WaitTool.waitFor(appiumDriver, ExpectedConditions.visibilityOf(walletLabel), DefaultWaitElementTime4Page);

    }

    public TradeCaptialPage NavigationToTradeCaptialPage() throws Exception {
        return click(tradeCaptialButton, TradeCaptialPage.class);
    }

    public PersonalInformationPage ToPersonalInformatinPage() throws Exception {
        return click(photoButton, PersonalInformationPage.class);
    }
    public InsurancePage NavigationToInsurancePage() throws Exception {
    	return click(insuranceButton, InsurancePage.class);
    }
    public PacketAndTicketPage NavigationToPacketAndTicketPage() throws Exception
    {
    	return click(packetAndTicketButton, PacketAndTicketPage.class);
    }
    public LendBorrowEarnListPage WalletToLendListPage() throws Exception{
    	return click(lendButton, LendBorrowEarnListPage.class);
    }
    public LendBorrowEarnListPage WalletToBorrowListPage() throws Exception{
    	return click(borrowButton, LendBorrowEarnListPage.class);
    }
    public LendBorrowEarnListPage WalletToEarnListPage() throws Exception{
    	return click(earnButton, LendBorrowEarnListPage.class);
    }

}
